package com.baizhi.reflect2;

import java.lang.reflect.Method;

/**
 * 通过反射获取成员方法
 */
public class MethodDemo {
    public static void main(String[] args) throws NoSuchMethodException {
        Class<Person> pClass = Person.class;

        //获取所有方法
        Method[] methods = pClass.getDeclaredMethods();
        for (Method method : methods) {
            System.out.println(method);
        }


        Method method1 = pClass.getDeclaredMethod("method1",null);
        System.out.println(method1);

        Method method2 = pClass.getDeclaredMethod("method2", String.class);
        System.out.println(method2);


        Method method5 = pClass.getDeclaredMethod("method5", null);
        System.out.println(method5);

    }
}
